# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=smpeg2
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=2
pkgdesc="SDL2 MPEG Player Library (mingw-w64)"
arch=('any')
url="http://icculus.org/smpeg/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "subversion")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-SDL2")
options=('staticlibs' 'strip')
noextract=(${_realname}-${pkgver}.tar.gz)
source=("${_realname}::svn://svn.icculus.org/smpeg/tags/release_${pkgver//./_}")
md5sums=('SKIP')

prepare() {
  cd "${srcdir}"/${_realname}
  ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --mandir=${MINGW_PREFIX}/share/man \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  
  # hacky way of resolving conflicts
  rm ${pkgdir}${MINGW_PREFIX}/bin/plaympeg
  rm -r ${pkgdir}${MINGW_PREFIX}/share/man
}
